/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TMS_GUI.java
 *
 * Created on Oct 31, 2011, 11:00:02 PM
 */

/**
 *
 * @author Zachary
 */
public class TMS_GUI extends javax.swing.JFrame {
    
    /** Creates new form TMS_GUI */
    public TMS_GUI() {
        initComponents();
        //Initialize the TMS subsystem
        tms_subsystem = new TMS();
        displayTimer = new javax.swing.Timer(100,
                new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                handleTimer(evt);
            }
        });
        displayTimer.setRepeats(true);
        displayTimer.start();
        inputString = "";
        usingKeyboard = false;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        workOutModeButtons = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        mainOutputDisplay = new javax.swing.JTextArea();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        controlPanel = new javax.swing.JPanel();
        inclinePanel = new javax.swing.JPanel();
        inclineUpButton = new javax.swing.JButton();
        inclineDownButton = new javax.swing.JButton();
        speedPanel = new javax.swing.JPanel();
        speedUpButton = new javax.swing.JButton();
        speedDownButton = new javax.swing.JButton();
        startPanel = new javax.swing.JPanel();
        stopButton = new javax.swing.JButton();
        pauseButton = new javax.swing.JButton();
        startButton = new javax.swing.JButton();
        safetyClip = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        radioFreeRun = new javax.swing.JRadioButton();
        radioCalorieBurn = new javax.swing.JRadioButton();
        radioInterval = new javax.swing.JRadioButton();
        radioTimedRun = new javax.swing.JRadioButton();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        historyOutputDisplay = new javax.swing.JTextArea();
        loginButton = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        keyZero = new javax.swing.JButton();
        keyNine = new javax.swing.JButton();
        keyEight = new javax.swing.JButton();
        keySeven = new javax.swing.JButton();
        keySix = new javax.swing.JButton();
        keyFive = new javax.swing.JButton();
        keyFour = new javax.swing.JButton();
        keyThree = new javax.swing.JButton();
        keyTwo = new javax.swing.JButton();
        keyOne = new javax.swing.JButton();
        keyQ = new javax.swing.JButton();
        keyW = new javax.swing.JButton();
        keyE = new javax.swing.JButton();
        keyR = new javax.swing.JButton();
        keyT = new javax.swing.JButton();
        keyY = new javax.swing.JButton();
        keyU = new javax.swing.JButton();
        keyI = new javax.swing.JButton();
        keyO = new javax.swing.JButton();
        keyP = new javax.swing.JButton();
        keyCancel = new javax.swing.JButton();
        keyEnter = new javax.swing.JButton();
        keyL = new javax.swing.JButton();
        keyK = new javax.swing.JButton();
        keyJ = new javax.swing.JButton();
        keyH = new javax.swing.JButton();
        keyG = new javax.swing.JButton();
        keyF = new javax.swing.JButton();
        keyD = new javax.swing.JButton();
        keyS = new javax.swing.JButton();
        keyA = new javax.swing.JButton();
        keyZ = new javax.swing.JButton();
        keyX = new javax.swing.JButton();
        keyC = new javax.swing.JButton();
        keyV = new javax.swing.JButton();
        keyB = new javax.swing.JButton();
        keyN = new javax.swing.JButton();
        keyM = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        mainOutputDisplay.setColumns(20);
        mainOutputDisplay.setEditable(false);
        mainOutputDisplay.setFont(new java.awt.Font("Monospaced", 1, 18));
        mainOutputDisplay.setLineWrap(true);
        mainOutputDisplay.setRows(5);
        mainOutputDisplay.setText("Main Output goes here\n");
        jScrollPane1.setViewportView(mainOutputDisplay);

        inclinePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Incline", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

        inclineUpButton.setText("Increase Incline");
        inclineUpButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                inclineUpButtonActionPerformed(evt);
            }
        });

        inclineDownButton.setText("Decrease Incline");
        inclineDownButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                inclineDownButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout inclinePanelLayout = new javax.swing.GroupLayout(inclinePanel);
        inclinePanel.setLayout(inclinePanelLayout);
        inclinePanelLayout.setHorizontalGroup(
            inclinePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(inclinePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(inclinePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(inclineUpButton, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(inclineDownButton, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        inclinePanelLayout.setVerticalGroup(
            inclinePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(inclinePanelLayout.createSequentialGroup()
                .addComponent(inclineUpButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(inclineDownButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        inclineUpButton.getAccessibleContext().setAccessibleName("");
        inclineDownButton.getAccessibleContext().setAccessibleName("");

        speedPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Speed", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

        speedUpButton.setText("Increase Speed");
        speedUpButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                speedUpButtonActionPerformed(evt);
            }
        });

        speedDownButton.setText("Decrease Speed");
        speedDownButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                speedDownButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout speedPanelLayout = new javax.swing.GroupLayout(speedPanel);
        speedPanel.setLayout(speedPanelLayout);
        speedPanelLayout.setHorizontalGroup(
            speedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(speedPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(speedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(speedUpButton, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(speedDownButton, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        speedPanelLayout.setVerticalGroup(
            speedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(speedPanelLayout.createSequentialGroup()
                .addComponent(speedUpButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(speedDownButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        speedUpButton.getAccessibleContext().setAccessibleName("");
        speedDownButton.getAccessibleContext().setAccessibleName("");

        startPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Start / Stop", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

        stopButton.setText("Stop");
        stopButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopButtonActionPerformed(evt);
            }
        });

        pauseButton.setText("Pause");
        pauseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pauseButtonActionPerformed(evt);
            }
        });

        startButton.setText("Start");
        startButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startButtonActionPerformed(evt);
            }
        });

        safetyClip.setText("safetyClip");
        safetyClip.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                safetyClipActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout startPanelLayout = new javax.swing.GroupLayout(startPanel);
        startPanel.setLayout(startPanelLayout);
        startPanelLayout.setHorizontalGroup(
            startPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(startPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(startPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(startButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pauseButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(stopButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, startPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(safetyClip, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        startPanelLayout.setVerticalGroup(
            startPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(startPanelLayout.createSequentialGroup()
                .addComponent(startButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pauseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(stopButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(safetyClip, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        stopButton.getAccessibleContext().setAccessibleName("");
        pauseButton.getAccessibleContext().setAccessibleName("");
        startButton.getAccessibleContext().setAccessibleName("");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Workout Mode", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

        workOutModeButtons.add(radioFreeRun);
        radioFreeRun.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        radioFreeRun.setSelected(true);
        radioFreeRun.setText("Free Run");

        workOutModeButtons.add(radioCalorieBurn);
        radioCalorieBurn.setFont(new java.awt.Font("Tahoma", 1, 12));
        radioCalorieBurn.setText("Calorie Burn");

        workOutModeButtons.add(radioInterval);
        radioInterval.setFont(new java.awt.Font("Tahoma", 1, 12));
        radioInterval.setText("Interval Training");
        radioInterval.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioIntervalActionPerformed(evt);
            }
        });

        workOutModeButtons.add(radioTimedRun);
        radioTimedRun.setFont(new java.awt.Font("Tahoma", 1, 12));
        radioTimedRun.setText("Timed Run");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(radioFreeRun)
                .addGap(21, 21, 21)
                .addComponent(radioCalorieBurn)
                .addGap(18, 18, 18)
                .addComponent(radioInterval)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(radioTimedRun)
                .addContainerGap(21, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(radioFreeRun)
                    .addComponent(radioTimedRun)
                    .addComponent(radioInterval)
                    .addComponent(radioCalorieBurn))
                .addContainerGap(25, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout controlPanelLayout = new javax.swing.GroupLayout(controlPanel);
        controlPanel.setLayout(controlPanelLayout);
        controlPanelLayout.setHorizontalGroup(
            controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(controlPanelLayout.createSequentialGroup()
                .addGap(58, 58, 58)
                .addGroup(controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(controlPanelLayout.createSequentialGroup()
                        .addComponent(inclinePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(startPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(speedPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(124, Short.MAX_VALUE))
        );
        controlPanelLayout.setVerticalGroup(
            controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(controlPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(speedPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(startPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(inclinePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Control", controlPanel);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("User History"));

        historyOutputDisplay.setColumns(20);
        historyOutputDisplay.setEditable(false);
        historyOutputDisplay.setRows(5);
        historyOutputDisplay.setMaximumSize(new java.awt.Dimension(4, 22));
        historyOutputDisplay.setRequestFocusEnabled(false);
        historyOutputDisplay.setVerifyInputWhenFocusTarget(false);
        jScrollPane2.setViewportView(historyOutputDisplay);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 606, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)
                .addContainerGap())
        );

        loginButton.setText("Login/Logout");
        loginButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loginButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(loginButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 638, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(loginButton, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("User", jPanel2);

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        keyZero.setText("0");
        keyZero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyZeroActionPerformed(evt);
            }
        });

        keyNine.setText("9");
        keyNine.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyNineActionPerformed(evt);
            }
        });

        keyEight.setText("8");
        keyEight.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyEightActionPerformed(evt);
            }
        });

        keySeven.setText("7");
        keySeven.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keySevenActionPerformed(evt);
            }
        });

        keySix.setText("6");
        keySix.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keySixActionPerformed(evt);
            }
        });

        keyFive.setText("5");
        keyFive.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyFiveActionPerformed(evt);
            }
        });

        keyFour.setText("4");
        keyFour.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyFourActionPerformed(evt);
            }
        });

        keyThree.setText("3");
        keyThree.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyThreeActionPerformed(evt);
            }
        });

        keyTwo.setText("2");
        keyTwo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyTwoActionPerformed(evt);
            }
        });

        keyOne.setText("1");
        keyOne.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyOneActionPerformed(evt);
            }
        });

        keyQ.setText("Q");
        keyQ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyQActionPerformed(evt);
            }
        });

        keyW.setText("W");
        keyW.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyWActionPerformed(evt);
            }
        });

        keyE.setText("E");
        keyE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyEActionPerformed(evt);
            }
        });

        keyR.setText("R");
        keyR.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyRActionPerformed(evt);
            }
        });

        keyT.setText("T");
        keyT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyTActionPerformed(evt);
            }
        });

        keyY.setText("Y");
        keyY.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyYActionPerformed(evt);
            }
        });

        keyU.setText("U");
        keyU.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyUActionPerformed(evt);
            }
        });

        keyI.setText("I");
        keyI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyIActionPerformed(evt);
            }
        });

        keyO.setText("O");
        keyO.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyOActionPerformed(evt);
            }
        });

        keyP.setText("P");
        keyP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyPActionPerformed(evt);
            }
        });

        keyCancel.setText("x");
        keyCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyCancelActionPerformed(evt);
            }
        });

        keyEnter.setText("Enter");
        keyEnter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyEnterActionPerformed(evt);
            }
        });

        keyL.setText("L");
        keyL.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyLActionPerformed(evt);
            }
        });

        keyK.setText("K");
        keyK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyKActionPerformed(evt);
            }
        });

        keyJ.setText("J");
        keyJ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyJActionPerformed(evt);
            }
        });

        keyH.setText("H");
        keyH.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyHActionPerformed(evt);
            }
        });

        keyG.setText("G");
        keyG.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyGActionPerformed(evt);
            }
        });

        keyF.setText("F");
        keyF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyFActionPerformed(evt);
            }
        });

        keyD.setText("D");
        keyD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyDActionPerformed(evt);
            }
        });

        keyS.setText("S");
        keyS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keySActionPerformed(evt);
            }
        });

        keyA.setText("A");
        keyA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyAActionPerformed(evt);
            }
        });

        keyZ.setText("Z");
        keyZ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyZActionPerformed(evt);
            }
        });

        keyX.setText("X");
        keyX.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyXActionPerformed(evt);
            }
        });

        keyC.setText("C");
        keyC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyCActionPerformed(evt);
            }
        });

        keyV.setText("V");
        keyV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyVActionPerformed(evt);
            }
        });

        keyB.setText("B");
        keyB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyBActionPerformed(evt);
            }
        });

        keyN.setText("N");
        keyN.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyNActionPerformed(evt);
            }
        });

        keyM.setText("M");
        keyM.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keyMActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(keyZ, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyX, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyC, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyV, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(3, 3, 3)
                                .addComponent(keyB, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyN, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyM, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(keyA, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyS, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyD, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyF, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyG, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyH, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyJ, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyK, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(keyL, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(keyEnter, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(keyQ, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyW, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyE, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyR, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyT, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyY, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyU, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyI, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyO, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyP, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(keyOne, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyTwo, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyThree, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyFour, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyFive, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keySix, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keySeven, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyEight, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyNine, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(keyZero, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(10, 10, 10)
                        .addComponent(keyCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(keyCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(keyOne, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyTwo, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyThree, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyFour, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyFive, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keySix, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keySeven, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyEight, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyNine, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyZero, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(keyQ, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyW, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyE, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyR, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyT, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyY, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyU, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyI, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyO, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(keyP, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(keyA, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyS, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyD, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyF, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyG, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyH, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyJ, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyK, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyL, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyEnter, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(keyZ, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyX, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyC, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyV, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyB, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyN, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keyM, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(145, 145, 145))
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Keyboard", jPanel4);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane1)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 663, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 388, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void handleTimer(java.awt.event.ActionEvent evt){
        if (usingKeyboard == false) this.mainOutputDisplay.setText(tms_subsystem.machineDisplay());        
        displayTimer.start();
    }
    private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed
        // TODO add your handling code here:
        tms_subsystem.start_workout();
    }//GEN-LAST:event_startButtonActionPerformed

    private void keyCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyCancelActionPerformed
        // TODO add your handling code here:
        if (inputString.length() > 0){
            inputString = inputString.substring(0,inputString.length() - 1);
        }
    }//GEN-LAST:event_keyCancelActionPerformed

    private void inclineUpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inclineUpButtonActionPerformed
        // TODO add your handling code here:
        tms_subsystem.incline_increase();
    }//GEN-LAST:event_inclineUpButtonActionPerformed

    private void inclineDownButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inclineDownButtonActionPerformed
        // TODO add your handling code here:
        tms_subsystem.incline_decrease();
    }//GEN-LAST:event_inclineDownButtonActionPerformed

    private void radioIntervalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioIntervalActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_radioIntervalActionPerformed

    private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pauseButtonActionPerformed
        // TODO add your handling code here:
        tms_subsystem.pause_workout();
    }//GEN-LAST:event_pauseButtonActionPerformed

    private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopButtonActionPerformed
        // TODO add your handling code here:
        tms_subsystem.stop_workout();
        historyOutputDisplay.setText(tms_subsystem.sessionHistory());
        if (tms_subsystem.loggedIn()) tms_subsystem.user_update();
    }//GEN-LAST:event_stopButtonActionPerformed

    private void safetyClipActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_safetyClipActionPerformed
        // TODO add your handling code here:
        if (tms_subsystem.SafetyClip.is_engaged()) tms_subsystem.SafetyClip.disengage();
        else tms_subsystem.SafetyClip.engage();
    }//GEN-LAST:event_safetyClipActionPerformed

    private void speedUpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_speedUpButtonActionPerformed
        // TODO add your handling code here:
        tms_subsystem.speed_increase();
    }//GEN-LAST:event_speedUpButtonActionPerformed

    private void speedDownButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_speedDownButtonActionPerformed
        // TODO add your handling code here:
        tms_subsystem.speed_decrease();
    }//GEN-LAST:event_speedDownButtonActionPerformed

    private void keyJActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyJActionPerformed
        // TODO add your handling code here:
        inputString += "J";
    }//GEN-LAST:event_keyJActionPerformed

    private void keyKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyKActionPerformed
        // TODO add your handling code here:
        inputString += "K";
    }//GEN-LAST:event_keyKActionPerformed

    private void keyOneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyOneActionPerformed
        // TODO add your handling code here:
        inputString += "1";
    }//GEN-LAST:event_keyOneActionPerformed

    private void keyTwoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyTwoActionPerformed
        // TODO add your handling code here:
        inputString += "2";
    }//GEN-LAST:event_keyTwoActionPerformed

    private void keyThreeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyThreeActionPerformed
        // TODO add your handling code here:
        inputString += "3";
    }//GEN-LAST:event_keyThreeActionPerformed

    private void keyFourActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyFourActionPerformed
        // TODO add your handling code here:
        inputString += "4";
    }//GEN-LAST:event_keyFourActionPerformed

    private void keyFiveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyFiveActionPerformed
        // TODO add your handling code here:
        inputString += "5";
    }//GEN-LAST:event_keyFiveActionPerformed

    private void keySixActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keySixActionPerformed
        // TODO add your handling code here:
        inputString += "6";
    }//GEN-LAST:event_keySixActionPerformed

    private void keySevenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keySevenActionPerformed
        // TODO add your handling code here:
        inputString += "7";
    }//GEN-LAST:event_keySevenActionPerformed

    private void keyEightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyEightActionPerformed
        // TODO add your handling code here:
        inputString += "8";
    }//GEN-LAST:event_keyEightActionPerformed

    private void keyNineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyNineActionPerformed
        // TODO add your handling code here:
        inputString += "9";
    }//GEN-LAST:event_keyNineActionPerformed

    private void keyZeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyZeroActionPerformed
        // TODO add your handling code here:
        inputString += "0";
    }//GEN-LAST:event_keyZeroActionPerformed

    private void keyQActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyQActionPerformed
        // TODO add your handling code here:
        inputString += "Q";
    }//GEN-LAST:event_keyQActionPerformed

    private void keyWActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyWActionPerformed
        // TODO add your handling code here:
        inputString += "W";
    }//GEN-LAST:event_keyWActionPerformed

    private void keyEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyEActionPerformed
        // TODO add your handling code here:
        inputString += "E";
    }//GEN-LAST:event_keyEActionPerformed

    private void keyRActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyRActionPerformed
        // TODO add your handling code here:
        inputString += "R";
    }//GEN-LAST:event_keyRActionPerformed

    private void keyTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyTActionPerformed
        // TODO add your handling code here:
        inputString += "T";
    }//GEN-LAST:event_keyTActionPerformed

    private void keyYActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyYActionPerformed
        // TODO add your handling code here:
        inputString += "Y";
    }//GEN-LAST:event_keyYActionPerformed

    private void keyUActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyUActionPerformed
        // TODO add your handling code here:
        inputString += "U";
    }//GEN-LAST:event_keyUActionPerformed

    private void keyIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyIActionPerformed
        // TODO add your handling code here:
        inputString += "I";
    }//GEN-LAST:event_keyIActionPerformed

    private void keyOActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyOActionPerformed
        // TODO add your handling code here:
        inputString += "O";
    }//GEN-LAST:event_keyOActionPerformed

    private void keyPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyPActionPerformed
        // TODO add your handling code here:
        inputString += "P";
    }//GEN-LAST:event_keyPActionPerformed

    private void keyAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyAActionPerformed
        // TODO add your handling code here:
        inputString += "A";
    }//GEN-LAST:event_keyAActionPerformed

    private void keySActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keySActionPerformed
        // TODO add your handling code here:
        inputString += "S";
    }//GEN-LAST:event_keySActionPerformed

    private void keyDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyDActionPerformed
        // TODO add your handling code here:
        inputString += "D";
    }//GEN-LAST:event_keyDActionPerformed

    private void keyFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyFActionPerformed
        // TODO add your handling code here:
        inputString += "F";
    }//GEN-LAST:event_keyFActionPerformed

    private void keyGActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyGActionPerformed
        // TODO add your handling code here:
        inputString += "G";
    }//GEN-LAST:event_keyGActionPerformed

    private void keyHActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyHActionPerformed
        // TODO add your handling code here:
        inputString += "H";
    }//GEN-LAST:event_keyHActionPerformed

    private void keyLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyLActionPerformed
        // TODO add your handling code here:
        inputString += "L";
    }//GEN-LAST:event_keyLActionPerformed

    private void keyZActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyZActionPerformed
        // TODO add your handling code here:
        inputString += "Z";
    }//GEN-LAST:event_keyZActionPerformed

    private void keyXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyXActionPerformed
        // TODO add your handling code here:
        inputString += "X";
    }//GEN-LAST:event_keyXActionPerformed

    private void keyCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyCActionPerformed
        // TODO add your handling code here:
        inputString += "C";
    }//GEN-LAST:event_keyCActionPerformed

    private void keyVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyVActionPerformed
        // TODO add your handling code here:
        inputString += "V";
    }//GEN-LAST:event_keyVActionPerformed

    private void keyBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyBActionPerformed
        // TODO add your handling code here:
        inputString += "B";
    }//GEN-LAST:event_keyBActionPerformed

    private void keyNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyNActionPerformed
        // TODO add your handling code here:
        inputString += "N";
    }//GEN-LAST:event_keyNActionPerformed

    private void keyMActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyMActionPerformed
        // TODO add your handling code here:
        inputString += "M";
    }//GEN-LAST:event_keyMActionPerformed

    private void keyEnterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyEnterActionPerformed
        // TODO add your handling code here:
        usingKeyboard = false;
    }//GEN-LAST:event_keyEnterActionPerformed

    private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginButtonActionPerformed
        // TODO add your handling code here:
        if (tms_subsystem.isRunning() == false && usingKeyboard == false){
            if (tms_subsystem.loggedIn() == false){
                new loginHandler().start();
            }else{
                tms_subsystem.user_logout();
            }
        }
        historyOutputDisplay.setText(tms_subsystem.sessionHistory());
    }//GEN-LAST:event_loginButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                TMS_GUI gui = new TMS_GUI();
                //new TMS_GUI().setVisible(true);
                gui.setVisible(true);
                
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JPanel controlPanel;
    private javax.swing.JTextArea historyOutputDisplay;
    private javax.swing.JButton inclineDownButton;
    private javax.swing.JPanel inclinePanel;
    private javax.swing.JButton inclineUpButton;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JButton keyA;
    private javax.swing.JButton keyB;
    private javax.swing.JButton keyC;
    private javax.swing.JButton keyCancel;
    private javax.swing.JButton keyD;
    private javax.swing.JButton keyE;
    private javax.swing.JButton keyEight;
    private javax.swing.JButton keyEnter;
    private javax.swing.JButton keyF;
    private javax.swing.JButton keyFive;
    private javax.swing.JButton keyFour;
    private javax.swing.JButton keyG;
    private javax.swing.JButton keyH;
    private javax.swing.JButton keyI;
    private javax.swing.JButton keyJ;
    private javax.swing.JButton keyK;
    private javax.swing.JButton keyL;
    private javax.swing.JButton keyM;
    private javax.swing.JButton keyN;
    private javax.swing.JButton keyNine;
    private javax.swing.JButton keyO;
    private javax.swing.JButton keyOne;
    private javax.swing.JButton keyP;
    private javax.swing.JButton keyQ;
    private javax.swing.JButton keyR;
    private javax.swing.JButton keyS;
    private javax.swing.JButton keySeven;
    private javax.swing.JButton keySix;
    private javax.swing.JButton keyT;
    private javax.swing.JButton keyThree;
    private javax.swing.JButton keyTwo;
    private javax.swing.JButton keyU;
    private javax.swing.JButton keyV;
    private javax.swing.JButton keyW;
    private javax.swing.JButton keyX;
    private javax.swing.JButton keyY;
    private javax.swing.JButton keyZ;
    private javax.swing.JButton keyZero;
    private javax.swing.JButton loginButton;
    private javax.swing.JTextArea mainOutputDisplay;
    private javax.swing.JButton pauseButton;
    private javax.swing.JRadioButton radioCalorieBurn;
    private javax.swing.JRadioButton radioFreeRun;
    private javax.swing.JRadioButton radioInterval;
    private javax.swing.JRadioButton radioTimedRun;
    private javax.swing.JButton safetyClip;
    private javax.swing.JButton speedDownButton;
    private javax.swing.JPanel speedPanel;
    private javax.swing.JButton speedUpButton;
    private javax.swing.JButton startButton;
    private javax.swing.JPanel startPanel;
    private javax.swing.JButton stopButton;
    private javax.swing.ButtonGroup workOutModeButtons;
    // End of variables declaration//GEN-END:variables
    private TMS tms_subsystem;
    private javax.swing.Timer displayTimer;
    private String inputString;
    private boolean usingKeyboard;
    

    class loginHandler extends Thread{
        public loginHandler(){

        }
        @Override
        public void run(){
            String message = "Enter User Name: ";
            String user_name = "";
            String user_pin  = "";
            inputString = "";
            usingKeyboard = true;
            while(usingKeyboard){
                mainOutputDisplay.setText(message + inputString);
            }
            user_name = inputString;

            message = "Enter User Pin: ";
            inputString = "";
            usingKeyboard = true;
            while(usingKeyboard){
                String hidden = "";
                for (int i = 0; i < inputString.length(); i++) hidden += "*";
                mainOutputDisplay.setText(message + hidden);
            }
            user_pin = inputString;
            tms_subsystem.user_login(user_name,Integer.parseInt(user_pin));
            historyOutputDisplay.setText(tms_subsystem.sessionHistory());
        }
    }
    
}
